package lt.hsu.thr;

import lombok.extern.slf4j.Slf4j;
import lt.hsu.web.EApiReturn;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class ThrAdvice {


    @ExceptionHandler(LtException.class)
    public String handleLtException(LtException ex) {
        log.info("Thr advice + LtException",ex);
        return "LtException: [" + ex.getCode() + "] -- [" + ex.getMessage() + "]";
    }

    @ExceptionHandler(RuntimeException.class)
    public String handleRuntimeException(RuntimeException ex) {
        log.info("Thr advice + " + ex.getClass().getName(),ex);
        return EApiReturn.FAILURE.getMessage() + " -- " + ex.getMessage();
    }
}
